#!/bin/bash -e

np=$(cat /proc/cpuinfo | grep "cpu cores" | uniq | awk '{print $NF}')
echo "nprocs in this machine is $np"

for i in 4; do
    if [[ $i -gt $np ]]; then
        continue
    fi
    echo "TEST in parallel, nprocs=$i"
    mpirun -np $i ./MODULE_CELL_SEP_CELL_TEST
    if [[ $? -ne 0 ]]; then
        echo -e "\e[1;33m [  FAILED  ] \e[0m" \
            "execute UT with $i cores error."
        exit 1
    fi
    break
done
